package org.fu.crowd.api;

import org.fu.crowd.utils.Common;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.concurrent.TimeUnit;

@Component
@FeignClient("CLOUD-REDIS-SERVICE")
public interface RedisRemoteService {

    /**
     * 在redis中保存数据
     * @param key
     * @param value
     * @return
     */
    @RequestMapping("/set/RedisKeyValue/Remote")
    Common<String> setRedisKeyValueRemote(@RequestParam("key")String key,
                                                 @RequestParam("value")String value);



    /**
     * 在redis中保存数据,有过期时间
     * @param key
     * @param value
     * @return
     */
    @RequestMapping("/set/RedisKeyValue/RemoteWithTimeOut")
    Common<String> setRedisKeyValueRemoteWithTimeOutRemote(
            @RequestParam("key")String key,
            @RequestParam("value")String value,
            @RequestParam("time")Long time,
            @RequestParam("timeUnix")TimeUnit timeUnit);


    /**
     * 根据key 获取value
     * @param key
     * @return
     */
    @RequestMapping("/get/RedisValue/ByKey")
    Common<String> getRedisValueByKeyRemote( @RequestParam("key")String key);


    /**
     *      根据key 删除value
     * @param key
     * @return
     */
    @RequestMapping("/removeRedisValue/ByKeyRemote")
    Common<String> removeRedisValueByKeyRemote( @RequestParam("key")String key);


}
